import 'package:flutter/material.dart';

class PopupMenuButtonDemo extends StatefulWidget {
  @override
  _PopupMenuButtonDemoState createState() => _PopupMenuButtonDemoState();
}

class _PopupMenuButtonDemoState extends State<PopupMenuButtonDemo> {

  String _currentPopupMenu = 'A';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('PopupMenuButtonDemo'),
        elevation: 0.0,
        centerTitle: true,
      ),
      body: Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(_currentPopupMenu),
                PopupMenuButton(
                  onSelected: (value) {
                    setState(() {
                      _currentPopupMenu = value;
                    });
                  },
                  itemBuilder: (BuildContext context) => [
                    PopupMenuItem(
                      value: 'A',
                      child: Text('A'),
                    ),
                    PopupMenuItem(
                      value: 'B',
                      child: Text('B'),
                    ),
                    PopupMenuItem(
                      value: 'C',
                      child: Text('C'),
                    ),
                    PopupMenuItem(
                      value: 'D',
                      child: Text('D'),
                    ),
                  ],
                )
              ],
            )
          ],
        ),
      ),
    );
  }
}
